﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections.Generic;
using SD.Database.Classes;
using DBAccess;
namespace SD.Database
{
    public class Stats
    {
        public static double GetAvgProduction()
        {
            try
            {
                return DAL.GetInstance().GetDouble("SELECT AVG(Factories + PopulationLevel) FROM Planets WHERE (OwnerID > 1)");
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public static double GetAVG(string science)
        {
            try
            {
                return DAL.GetInstance().GetDouble("Select AVG(" + science + ") From Players Where PlayerId > 1");
            }
            catch (Exception)
            {
                return 0;
            }
        }
        public static Dictionary<string, double> AvgSciences()
        {
            Dictionary<string, double> tmp = new Dictionary<string, double>();
            tmp.Add("Biology", GetAVG("Biology"));
            tmp.Add("Economy", GetAVG("Economy"));
            tmp.Add("Energy", GetAVG("Energy"));
            tmp.Add("Math", GetAVG("Math"));
            tmp.Add("Physics", GetAVG("Physics"));
            tmp.Add("Social", GetAVG("Social"));
            tmp.Add("Culture", GetAVG("CurrentCulture"));
            return tmp;
        }
    };

}